﻿/*版权声明
 * 
 * 本 WebName:IMIS_ERP 由
 * 河北大学 信管团队 开发
 * 如有任何疑问请联系开发人员
 * 
 * 项目开发者
 * 负责人：朱胜贤
 * 成员：水亚亚、孙旭峰、张文元、项玥、吕芳、吴凡、谢静、李亚慧
 *
 * 如有任何疑问请联系：河北大学信管团队
 * QQ：196396337
 * Email:zagelover@163.com
 * HomePage：http://sxgzs.com/
 *
 * CopyRight (c) 河北大学信管团队 2010~2020
 */

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using IMIS_ERP.Model;
namespace IMIS_ERP.BLL
{
    /// <summary>Head_FacTake
    ///     <remarks>2010-12-31 河北大学信管团队</remarks>
    /// </summary>
    public class Head_FacTake
    {
        private readonly IMIS_ERP.DAL.Head_FacTake dal = new IMIS_ERP.DAL.Head_FacTake();
        public Head_FacTake()
        { }
        #region  Method

        /// <summary>是否存在该记录
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="hfID">编号</param>
        /// <returns>返回是否存在</returns>
        public bool Exists(int hfID)
        {
            return dal.Exists(hfID);
        }

        /// <summary>增加一条数据
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否添加成功</returns>
        public bool Add(IMIS_ERP.Model.Head_FacTake model)
        {
            return dal.Add(model);
        }

        /// <summary>更新一条数据
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否修改成功</returns>
        public bool Update(IMIS_ERP.Model.Head_FacTake model)
        {
            return dal.Update(model);
        }

        /// <summary>删除一条数据
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="hfID">编号</param>
        /// <returns>返回是否删除成功</returns>
        public bool Delete(string hfID)
        {

            return dal.Delete(hfID);
        }

        /// <summary>获取原材料消耗列表
        ///      <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="fiID">工厂编号</param>
        /// <param name="fiTime">时间</param>
        /// <returns>返回是否删除成功</returns>
        public SqlDataReader CreateList(string fiID, string fiTime)
        {
            return dal.CreateList(fiID, fiTime);
        }

        /// <summary>批量删除记录
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="hfIDlist">编号列表</param>
        /// <returns>返回删除的记录条数</returns>
        public int DeleteList(string hfIDlist)
        {
            return dal.DeleteList(hfIDlist);
        }

        /// <summary>得到一个对象实体
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="hfID">编号</param>
        /// <returns>返回Model</returns>
        public IMIS_ERP.Model.Head_FacTake GetModel(int hfID)
        {

            return dal.GetModel(hfID);
        }

        /// <summary>获得加工中心某段时间的报表
        ///     <remarks>2011-05-10 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="fiProvince">省</param>
        /// <param name="fiCity">市</param>
        /// <param name="oiTime1">开始时间</param>
        /// <param name="oiTime2">结束时间</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetRpt(string fiProvince, string fiCity, string oiTime1, string oiTime2)
        {
            return dal.GetRpt(fiProvince, fiCity, oiTime1, oiTime2);
        }

        /// <summary>获得数据列表
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>获得前几行数据
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="Top">行数</param>
        /// <param name="strWhere">条件</param>
        /// <param name="filedOrder">排序</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>获得数据列表
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Head_FacTake> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>获得数据列表
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Head_FacTake> DataTableToList(DataTable dt)
        {
            List<IMIS_ERP.Model.Head_FacTake> modelList = new List<IMIS_ERP.Model.Head_FacTake>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                IMIS_ERP.Model.Head_FacTake model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new IMIS_ERP.Model.Head_FacTake();
                    if (dt.Rows[n]["hfID"].ToString() != "")
                    {
                        model.hfID = int.Parse(dt.Rows[n]["hfID"].ToString());
                    }
                    if (dt.Rows[n]["hfTime"].ToString() != "")
                    {
                        model.hfTime = DateTime.Parse(dt.Rows[n]["hfTime"].ToString());
                    }
                    model.hfFiID = dt.Rows[n]["hfFiID"].ToString();
                    model.hfType = dt.Rows[n]["hfType"].ToString();
                    model.hfPcID = dt.Rows[n]["hfPcID"].ToString();
                    if (dt.Rows[n]["hfNum"].ToString() != "")
                    {
                        model.hfNum = int.Parse(dt.Rows[n]["hfNum"].ToString());
                    }
                    if (dt.Rows[n]["hfWeight"].ToString() != "")
                    {
                        model.hfWeight = decimal.Parse(dt.Rows[n]["hfWeight"].ToString());
                    }
                    if (dt.Rows[n]["hfPrice"].ToString() != "")
                    {
                        model.hfPrice = decimal.Parse(dt.Rows[n]["hfPrice"].ToString());
                    }
                    if (dt.Rows[n]["hfFee"].ToString() != "")
                    {
                        model.hfFee = decimal.Parse(dt.Rows[n]["hfFee"].ToString());
                    }
                    if (dt.Rows[n]["hfFeeNow"].ToString() != "")
                    {
                        model.hfFeeNow = decimal.Parse(dt.Rows[n]["hfFeeNow"].ToString());
                    }
                    model.hfRemark = dt.Rows[n]["hfRemark"].ToString();
                    model.hfHuID = dt.Rows[n]["hfHuID"].ToString();
                    model.hfVoucher = dt.Rows[n]["hfVoucher"].ToString();
                    if (dt.Rows[n]["hfIsPay"].ToString() != "")
                    {
                        if ((dt.Rows[n]["hfIsPay"].ToString() == "1") || (dt.Rows[n]["hfIsPay"].ToString().ToLower() == "true"))
                        {
                            model.hfIsPay = true;
                        }
                        else
                        {
                            model.hfIsPay = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>获得数据列表
        ///     <remarks>2010-12-31 河北大学信管团队</remarks>
        /// </summary>
        /// <returns>返回DataSet</returns>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>获得报表数据
        ///     <remarks>2011-08-10 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="time1">开始时间</param>
        /// <param name="time2">结束时间</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList_Report(string time1, string time2)
        {
            return dal.GetList_Report(time1, time2);
        }

        #endregion  Method
    }
}

